package com.weather;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;

/**
 * Activitate in care se selecteaza ziua folosind Radio Buttons
 *
 */

public class SelectDay extends Activity {

	private RadioButton [] radioButton = new RadioButton[4];

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		Intent intent = getIntent();
		
		setContentView(R.layout.select_day);
		
		int [] id = new int [] {R.id.option1, R.id.option2, R.id.option3, R.id.option4};
		
		for(int i=0; i<4; i++) {
			radioButton[i] = (RadioButton) findViewById(id[i]);
			radioButton[i].setText(intent.getStringExtra(Character.toString((char) ('0'+i))));
		}
		
		Button select = (Button) findViewById(R.id.select);
    	select.setOnClickListener(new OnClickListener() {
		    public void onClick(View v) {
		    	for(int i=0; i<4; i++) {
		    		if(radioButton[i].isChecked() == true) {
		    			Intent answer = new Intent();
		    			setResult(i, answer);
		    			finish();
		    		}
		    	}
		    	
		    }
		});
	}
	
	
}
